Vue.filter('formatMoney', function (value) {
    // 返回处理后的值
    if (!value) return '0.00'
    value = Number(value).toFixed(2);
    value = String(value);
    var reg = value.indexOf('.') > -1 ? /(\d{1,3})(?=(?:\d{3})+\.)/g : /(\d{1,3})(?=(?:\d{3})+$)/g; //千分符的正则
    value = value.replace(reg, '$1,'); //千分位格式化
    return "￥" + value
})
Vue.filter("formatCount", function (value) {
    if (!value) return ''
    return "x" + value
})
Vue.filter("encryptionPhone", function (value) {
    if (!value) return '';
    var reg = /^(\d{3})\d{4}(\d{4})$/;
    return value.replace(reg, "$1****$2")
})
Vue.filter("ossImg", function (value, size) {
    if (size == undefined) size = 100;
    if (value.indexOf('https://cdn.weitao.kr') == '-1') {
        return value
    }
    return value + "&x-oss-process=image/resize,m_fill,w_" + size + ",h_" + size
})

Vue.filter("encryptionNickName", function (value) {
    console.log(value);
    // if (!value) return '';
    // var reg = /^([\S]{1})*([\S]{1})$/;
    if (value == '暂未绑定') {
        return value
    } else if (value == null) {
        return '暂未绑定'
    } else {
        return value.slice(0, 1) + "***" + value.slice(length - 1)
    }
})

Vue.filter("formatEndTimeM", function (value, duration) {
    return new Date(value.replace(/-/g, '/')).getTime() + duration * 60 * 60 * 1000;
})
Vue.filter("btnImg", function (value, duration) {
    if (duration) {
        switch (duration) {
            case "modify":
                return '修改'
            case "refresh":
                return '刷新'
            case "add":
                return '新增'
            case "search":
                return '筛选'
            case "delete":
                return '删除'
            case "submit":
                return '提交'
            case "sure":
                return '确定'
        }
    } else {
        return '../img/' + value + '.png'
    }
})
Vue.filter("resetFrormSelectValue", function (val, array) {
    var name = ''
    array.map(function (item) {
        if (item.value == val.trim()) {
            name = item.name == "all" ? "全部" : item.name;
            return;
        }
    })
    return name
})
Vue.filter("nullable", function (item,data) {
    if (data.is_nullable == "Y") {  
        return data.show_name
    } else {
        return data.show_name + "*"
    }
})